package edu.ubbcs.rs.backend.model.table;

import edu.ubbcs.rs.backend.model.Reservation;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import javax.persistence.Entity;

/**
 * @author Merli Andras-Bertalan
 * @version 1.0
 * @created 09-jan.-2015 15:37:45
 */
@Entity
@javax.persistence.Table(name = "SimpleTables")
public class SimpleTable extends Table {

    public SimpleTable() {
    }

    /**
     *
     * @param weight
     * @param height
     * @param y
     * @param x
     */
    public SimpleTable(int weight, int height, int y, int x) {
        this.weight = weight;
        this.height = height;
        this.y = y;
        this.x = x;
    }

    @Override
    public boolean isReserved(List<Reservation> reservations) {
        for (Reservation reservation : reservations) {
            if (reservation.getTable().equals(this)) {
                return true;
            }
        }
        return false;
    }

    @Override
    public List<Reservation> reserve(Reservation reservation) {
        reservation.setTable(this);
        return Arrays.asList(reservation);
    }
}